<template>
    用户名:<input type="text" v-model="uname"><br>
    密码:<input type="text" v-model="pword"><br>
    <button @click="submit">登录</button>
</template>

<script>
import axios from 'axios'
export default {
    name:'Login',
    data(){
        return{
            uname:'',
            pword:''
        }
    },
    methods:{
        submit(){
            var url = '/aabbcc/login/namePassLogin';
			const that = this;
            axios({
                method: 'post',
                url: url,
                headers:{
                    'Content-Type': 'application/json'
                },
                data: {
                    username: this.uname,
                    password: this.pword
                },
                timeout: 1000,
            }).then(function(response){
                if(response.data.code == 200){
                    //把token放到浏览器内存中
                    var token = response.data.token;
                    //把token保存到浏览器内存中
                    localStorage.setItem('token',token);
                    //跳转到首页
                    that.$router.replace({
                        path:'/main'
                    });
                }
                console.log(response);
            })
        }
    }
}
</script>

<style>

</style>